package com.sunny.springboot2.controller;

import com.sunny.springboot2.core.exception.CustomException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 全局异常测试controller
 * @author sunny
 * @date 2018/11/27
 */
@RestController
@RequestMapping("exception")
public class ExceptionController {

    @GetMapping("/testException")
    public String testException(Integer num) throws CustomException {
        if (num == null) {
            throw new CustomException(500, "异常啦！！");
        }
        num = 10 / num;
        return "no exception num=" + num;
    }
}
